		$(document).ready(function(){			
			var  bid = getUrlParam('bid');
			var  like = "";
			$.ajax({
				url:d+"/bookdetail",
				type:"POST",
				data:JSON.stringify({bid:bid}),
				contentType:'application/json;charset=utf-8',
				dataType:"json",
				success:function(data){
						var str=('<div data-role="controlgroup">'+
								'<a href="#" data-role="button">'+data['book'].bname+'</a>'+
								'<a href="#" data-role="button">'+data['book'].bauthor+'</a>'+
								'<a href="#" data-role="button"><img src="'+data['book'].bimg+'" style="width:50%;"/></a>'+
								'<a href="#" data-role="button">简介</a>'+
								'</div>'+
								'<div data-role="content">'+
								'<p>'+data['book'].bintroduction+'</p>'+
								'</div>');
						var like=data['book'].bwant;
						$("#bcontent").append(str);
						$("#bcontent").trigger('create');
						$("#likeCount1").append(like);
						$("#likeCount1").trigger('create');
				},
				error:function(data){
					//alert("服务器繁忙");
				}
			});
			
			
	//点赞
	$('body').on("click",'.heart',function(){
    	var A=$(this).attr("id");
    	var B=A.split("like");
        var messageID=B[1];
        var like=parseInt($("#likeCount"+messageID).html());
    	$(this).css("background-position","")
        var D=$(this).attr("rel");
       
        if(D === 'like') 
        {      
        $("#likeCount"+messageID).html(like+1);
        $(this).addClass("heartAnimation").attr("rel","unlike");
        like++;
        }
        else
        {
        $("#likeCount"+messageID).html(like-1);
        $(this).removeClass("heartAnimation").attr("rel","like");
        $(this).css("background-position","left");
        like--;
        }

			$.ajax({
				url:d+"/bookwant",
				type:"POST",
				data:JSON.stringify({bid:bid,bwant:like}),
				contentType:'application/json;charset=utf-8',
				dataType:"json",
				success:function(data){

				},
				error:function(data){
//					alert("服务器繁忙");
				}
			});		
    	});	
    	
    	
    	//显示评论
			$.ajax({
				type:"POST",
				url:d+"/brlist",
				data:JSON.stringify({bid:bid}),
				contentType:'application/json;charset=utf-8',
				dataType:"json",
				success:function(data){
					for(var i=0;i<data['review'].length;i++){
						var str=('<li data-icon="false">'+
						'<font size="4" color="#22C3AA"><b>游客</b></font><br>'+
						'<font size="4" color="#000000"><p>'+data['review'][i].rcontent+'</p></font>'+
						'</li>');
						$("#rlist").append(str);
						$("#rlist").listview('refresh');
					}
				},
				error:function(data){
					//alert("服务器繁忙");
				}
			});
			
			
    	//发送评论
			$("#sendit").on("click",function(){
				$.ajax({
					type:"POST",
					url:d+"/brsend",
					data:JSON.stringify({bid:bid,rcontent:$('#rset textarea').val()}),
					contentType:'application/json;charset=utf-8',
					success:function(data){
						alert("评论成功");
					},
					error:function(data){
						alert("评论失败");
					}
				});
			});

});
